package com.gxa.cart.filter;

import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

/**
 * Created by bill on 2021/1/6
 **/
@Slf4j
@Activate
public class CartFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        Result rs = null;
        try {
            String clientIp = RpcContext.getContext().getRemoteHost();
            log.info("远程地址ip:{}",clientIp);
            //放行之前
            rs = invoker.invoke(invocation);
            //放行之后
        }catch (Exception e) {
            //异常处理
         log.error(e.getMessage());
        }
       //返回service处理结果
        return rs;
    }

}
